package frame.options.simulation.create.cost;

import model.algorithms.linksMapping.LinksMappingAlgorithm;

import com.nexes.wizard.WizardPanelDescriptor;

import frame.options.simulation.create.CreateSimulationWizard;
import frame.options.simulation.create.links.LinksDescriptor;

public class CostDescriptor extends WizardPanelDescriptor
{
	public static final String IDENTIFIER = CostDescriptor.class.getSimpleName();
	
	private CostPanel costPanel;
	public CostPanel getCostPanel(){ return costPanel; }
	public void setCostPanel( CostPanel costPanel ){ this.costPanel = costPanel; }
	
	public CostDescriptor()
    {
		this.setCostPanel( new CostPanel() );
		
		this.setPanelDescriptorIdentifier( CostDescriptor.IDENTIFIER );
    	this.setPanelComponent( this.getCostPanel() );
    }
    
    @Override
	public Object getBackPanelDescriptor()
    {
    	return LinksDescriptor.IDENTIFIER;
    }
    
    @Override
	public Object getNextPanelDescriptor()
    {
    	if( this.getCostPanel().getDistanceRadioButton().isSelected() )
    		( (CreateSimulationWizard) this.getWizard() ).setCostMetric( LinksMappingAlgorithm.DISTANCE_COST );
    	
    	else if( this.getCostPanel().getBandwidthRadioButton().isSelected() )
    		( (CreateSimulationWizard) this.getWizard() ).setCostMetric( LinksMappingAlgorithm.BW_COST );
    	
    	return WizardPanelDescriptor.FINISH;
    }
    
    @Override
	public void aboutToDisplayPanel()
    {
    	this.getWizard().setNextFinishButtonEnabled( true );
    }
    
}
